﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;
using System.Data;

public partial class admin_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            return;
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (!IsPostBack)
        {
            return;
        }


        NameValueCollection args = Request.Form;

        bool bLoginSucc = false;
        if (args != null)
        {
            string strUserName = args["username"].Trim();
            string strUserpass = args["passwd"].Trim();

            string strsql = string.Format("SELECT * FROM [userinfo] where [u_name] = '{0}'", strUserName);

            ManageData md = new ManageData(util.DATACONNECTION);
            if (md != null)
            {
                DataSet ds = md.ExecDS(strsql);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["u_passwd"].ToString() == strUserpass)
                    {
                        bLoginSucc = true;

                        CUser c = new CUser();

                        c.strId = ds.Tables[0].Rows[0]["u_id"].ToString();
                        c.strPassWd = ds.Tables[0].Rows[0]["u_passwd"].ToString();
                        c.strUserName = ds.Tables[0].Rows[0]["u_name"].ToString();
                        c.strShow = ds.Tables[0].Rows[0]["u_show"].ToString();
                        c.strPower = ds.Tables[0].Rows[0]["u_power"].ToString();

                        Session["login"] = c;

                        Response.Redirect("./Default.aspx");



                    }
                }
            }

        }

        if (!bLoginSucc)
        {
            Response.Write(util.GetResponseAlert("登录失败！"));
        }
    }


 
}
